$(document).ready(function() {
  var setClose = null, idle = false;
  var closingTime = 5000;
  var animSpeed = 300;
  var $panels = $('div.panel_container');
  $('div.panel_body').hide();
  
  var closeAll = function() {
    setClose = setTimeout(function() {
          idle = true;
          goDown($('div.panel_container').filter(".showing"));
        },closingTime);
  };
  var resetClose = function() {
    clearTimeout(setClose);
    closeAll();
  };
  
  closeAll();
  function goUp($el) {
    var isHidden = $el.find('div.panel_body:hidden').length > 0;
    $el.not(".showing")
         .addClass("showing")
         .find("div.panel_body")
         .queue("fx", [])
         .stop()
         .animate({height: (isHidden ? 'show' : '150px')}, animSpeed, function () {
              $(this).height("").prev().addClass('visible');
            });
  }
  function goDown($el) {
    $el.filter(".showing")
         .removeClass("showing")
         .find("div.panel_body")
         .queue("fx", [])
         .stop()
         .animate({height:'hide'}, animSpeed, function () {
              $(this).height("").prev().removeClass('visible');
            });
  }
  function slideTabs() {
    var overTab = this;
    $("div.panel_container").each(function () {
          if (overTab == this) {
            resetClose();
            goUp($(overTab));
          } else {
            goDown($(this));
          }
        });
  }
  $('div.panel_container').click(slideTabs);

  $('html, body').mousemove(function() {
        if (idle) idle = false;
      });  

});
